/*
 * @Descripttion: 
 * @version: 
 * @Author: 高月飞
 * @Date: 2023-11-17 21:34:02
 * @LastEditors: 高月飞
 * @LastEditTime: 2023-11-25 08:32:42
 */

//网络请求

import { userCustomerlogMessageApi } from "@/services/customer";
import type { ICustomerData } from "@/types/customer";
import { defineStore } from "pinia";
const useLogStore = defineStore('log', {
    //持久化操作
    //对于登录信息进行一次持久化操作
    persist: {
        storage: window.sessionStorage,
        paths: ['loginfo']
    },

    state: () => ({
        loginfo: {
            operator: "",
            operationtype: "",
            operationfield: "",
        }
    }) as ICustomerData.IRootstore5,

    actions: {
        SETLOGINFO(data: ICustomerData.IRootInterface5) {
            this.loginfo = data
        },
        SETUSERLOGOUT() {
            this.loginfo = {

                operator: "",
                operationtype: "",
                operationfield: "",
            }
        },
        async USEPLOGCTION(id: number) {
            let ret = await userCustomerlogMessageApi(id)
            if (ret.code === 200) {
                this.SETLOGINFO(ret.data)
            }
            return ret.data
        }

    },


})
export default useLogStore
